﻿<%@ Page Language="C#" AutoEventWireup="true" %>

<%@ Import Namespace="wnxd.javascript" %>
<%@ Import Namespace="Hidistro.Membership.Context" %>
<%@ Import Namespace="Hidistro.Membership.Core" %>
<%@ Import Namespace="Hidistro.SaleSystem.Shopping" %>
<%@ Import Namespace="Hidistro.Entities.Sales" %>
<script runat="server">
    protected void Page_Load(object sender, EventArgs e)
    {
        json ret = new json(new { user = new { error = -1 }, shopcart = new { error = -1 } });
        IUser user = HiContext.Current.User;
        if (!user.IsAnonymous)
        {
            ret["user"]["error"] = 0;
            ret["user"]["name"] = user.Username;
        }
        ShoppingCartInfo shoppingCart = ShoppingCartProcessor.GetShoppingCart();
        if ((shoppingCart != null) && ((shoppingCart.LineGifts.Count > 0) || (shoppingCart.LineItems.Count > 0)))
        {
            ret["shopcart"]["error"] = 0;
            ret["shopcart"]["count"] = shoppingCart.GetQuantity();
        }
        this.Response.Write(ret.ToString());
    }
</script>
